/* 
 节流
 
 页面内使用
 import { useThrottle } from '@/hooks/useThrottle.js'
 const { throttle  } = useThrottle()
 throttle (() => {
	// 事件逻辑
	
 },100)
 */

const useThrottle = () => {
	const valid = ref(true)

	const throttle = (fn, delay = 100) => {
		if(!valid.value) {
			return false
		}
		valid.value = false
		setTimeout(() => {
			fn()
		}, delay)
	}

	return { throttle }
}

export { useThrottle }
